package com.cts.learninglibrary.controller;

import com.cts.learninglibrary.dto.ShareDTO;
import com.cts.learninglibrary.service.ShareService;
import com.cts.learninglibrary.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: kwanghuee
 * @date: 2020/8/18 10:48
 */
@RestController
@CrossOrigin
@RequestMapping("/share")
public class ShareController {

    @Autowired
    private ShareService shareService;

    /**
     * 保存分享
     * @param shareDTO
     * @return
     */
    @PostMapping("/saveShare")
    public R saveShare(@RequestBody ShareDTO shareDTO){
        return R.ok(shareService.saveShare(shareDTO));
    }

    /**
     * 首页展示分享
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/queryByPage")
    public R queryByPage(Integer pageNo, Integer pageSize) {
        return R.ok(shareService.queryByPage(pageNo,pageSize));
    }
}
